<?php

namespace app\adminmini\model;

use think\facade\Db;

class Region extends BaseModel
{
    protected $name = "distribution_price";

    public function getInfo($id)
    {
        $info = Db::name('distribution_price')->where('id', $id)->find();

        $info['price'] = $info['price'] . '元';
        $order['price'] = '';
        switch ($info['type']) {
            case 1:
                $order = Db::name('customer_order')->where('id', $info['order_id'])->find();
                if ($order) {
                    $user = Db::name('member')->where('id', $order['user_id'])->find();

                }

                break;
            case 2:
                $order = Db::name('customer_level_order')->where('id', $info['order_id'])->find();

                if ($order) {
                    $user = Db::name('member')->where('id', $order['user_id'])->find();
                }

                break;
            case 3:
                $order = Db::name('customer_seat_order')->where('id', $info['order_id'])->find();
                if ($order) {
                    $user = Db::name('member')->where('id', $order['user_id'])->find();

                }

                break;
            case 4:
                $order = Db::name('customer_recharge_order')->where('id', $info['order_id'])->find();

                if ($order) {
                    $user = Db::name('member')->where('id', $order['user_id'])->find();

                }

                break;
            case 5:
                $order = Db::name('customer_integral_product_order')->where('id', $info['order_id'])->find();

                if ($order) {
                    $user = Db::name('member')->where('id', $order['user_id'])->find();
                    $order['price'] = $order['pay_money'];
                }


                break;
            case 6:
                $order = Db::name('customer_order')->where('id', $info['order_id'])->find();
                if ($order) {
                    $user = Db::name('member')->where('id', $order['user_id'])->find();
                    $order['price'] = $order['pay_price'] - $order['retreat_price'];
                }

                break;
        }
        $info['order_price'] = $order['price'] . '元';
        $info['nickname'] = $user['nickname'];
        $info['mobile'] = $user['mobile'];
        $roomlist = Db::name('mini_room_list')->where('id', $info['direct_id'])->find();
        if ($roomlist) {
            $info['referrer'] = $roomlist['room_name'];

        }


        return $info;
    }
}